<template>
  <div class="feedback">
        <div class="header_group">
              <h6>意见反馈</h6>
              <p>您的反馈帮助我们成长~~</p>
        </div>
        <div class="message">
              <textarea v-model="message" placeholder="请填写您的个人意见"></textarea>
              <p>{{message.length}}/120</p>
        </div>
        <p class="commit" @click="commit();">保存</p>
  </div>
</template>

<script>
export default {
    data(){
        return{
            message:''
        }
    },
    watch:{
      'message':function(){
         this.message=this.message.substring(0,120);
      }
    },
    methods:{
      commit(){
        var _this=this;
        if(!_this.message){
          alert('请填写您的个人意见');
          return false;
        }
        _this.$http.post("/api/comnControl.do?saveCanxinSuggestionInfo",
                    {
                      id: sessionStorage.user_openid,
                      suggestion: _this.message
                    })
        .then(
          (response)=>{
            console.log(response);
            if(response.body.rtnCode=="ok"){
              alert("谢谢您的反馈，我们会尽快改进的哦");
              _this.$router.push({name:'center'});
            }
          },
          (error)=>{
            _this.finish=true;
            console.log(error);
          }
        );
      }
    }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
.feedback
{
    .header_group
    {
        padding:0.5rem 0;
        text-align:center;
        h6
        {
          color:#078def;
          font-size:0.5rem;
          margin-bottom:0.3rem;
        }
        p 
        {
          color:#999;
        }
    }
    .message
    {
      background:#fff;
      textarea
      {
        resize:none;
        border:none;
        width:100%;
        height:2.5rem;
        line-height:1.2;
        padding:0.2rem 0.3rem;
        -webkit-box-sizing: border-box;
           -moz-box-sizing: border-box;
                box-sizing: border-box;
      }
      p
      {
        color:#999;
        text-align:right;
        padding:0 0.3rem 0.1rem 0;
      }
    }
    .commit
    {
        margin:0.3rem 0.24rem;
        line-height:0.8rem;
        height:0.8rem;
        border-radius:0.1rem;
        border:1px solid #078def;
        text-align:center;
        background:#078def;
        color:#fff;
        font-size:0.32rem;
    }
}
</style>
